//
//  JackStringExtension.swift
//  ActualExaminationLine
//
//  Created by iOS-Czz on 2023/10/30.
//

import Foundation
extension String {
    func dayOfWeek() -> String? {
            let dateFormatter = DateFormatter()
            dateFormatter.dateFormat = "yyyy.MM.dd"

            if let date = dateFormatter.date(from: self) {
                dateFormatter.dateFormat = "EEEE"
                return dateFormatter.string(from: date)
            }
            return nil
        }
}
extension NSMutableAttributedString {
    
}
extension NSAttributedString {
    static func coloredString(originalText: String, coloredSubText: String, colorForColoredText: UIColor) -> NSAttributedString {
        let attributedString = NSMutableAttributedString(string: originalText)
        
        // 查找coloredSubText在原始文本中的范围
        if let range = originalText.range(of: coloredSubText) {
            let nsRange = NSRange(range, in: originalText)
            
            // 设置coloredSubText的颜色
            attributedString.addAttribute(.foregroundColor, value: colorForColoredText, range: nsRange)
        }
        
        return attributedString
    }
    
}
